package com.zxcrm.web.controller.zxcrm;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zxcrm.common.annotation.Log;
import com.zxcrm.common.core.controller.BaseController;
import com.zxcrm.common.core.domain.AjaxResult;
import com.zxcrm.common.enums.BusinessType;
import com.zxcrm.zxcrm.domain.ZxcrmBusinessContact;
import com.zxcrm.zxcrm.service.IZxcrmBusinessContactService;
import com.zxcrm.common.utils.poi.ExcelUtil;
import com.zxcrm.common.core.page.TableDataInfo;

/**
 * 商机和联系人关系表Controller
 * 
 * @author xu
 * @date 2025-07-11
 */
@RestController
@RequestMapping("/zxcrm/businessContact")
public class ZxcrmBusinessContactController extends BaseController
{
    @Autowired
    private IZxcrmBusinessContactService zxcrmBusinessContactService;

    /**
     * 查询商机和联系人关系表列表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:businessContact:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxcrmBusinessContact zxcrmBusinessContact)
    {
        startPage();
        List<ZxcrmBusinessContact> list = zxcrmBusinessContactService.selectZxcrmBusinessContactList(zxcrmBusinessContact);
        return getDataTable(list);
    }

    /**
     * 导出商机和联系人关系表列表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:businessContact:export')")
    @Log(title = "商机和联系人关系表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxcrmBusinessContact zxcrmBusinessContact)
    {
        List<ZxcrmBusinessContact> list = zxcrmBusinessContactService.selectZxcrmBusinessContactList(zxcrmBusinessContact);
        ExcelUtil<ZxcrmBusinessContact> util = new ExcelUtil<ZxcrmBusinessContact>(ZxcrmBusinessContact.class);
        util.exportExcel(response, list, "商机和联系人关系表数据");
    }

    /**
     * 获取商机和联系人关系表详细信息
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:businessContact:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zxcrmBusinessContactService.selectZxcrmBusinessContactById(id));
    }

    /**
     * 新增商机和联系人关系表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:businessContact:add')")
    @Log(title = "商机和联系人关系表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxcrmBusinessContact zxcrmBusinessContact)
    {
        return toAjax(zxcrmBusinessContactService.insertZxcrmBusinessContact(zxcrmBusinessContact));
    }

    /**
     * 修改商机和联系人关系表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:businessContact:edit')")
    @Log(title = "商机和联系人关系表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZxcrmBusinessContact zxcrmBusinessContact)
    {
        return toAjax(zxcrmBusinessContactService.updateZxcrmBusinessContact(zxcrmBusinessContact));
    }

    /**
     * 删除商机和联系人关系表
     */
    @PreAuthorize("@ss.hasPermi('zxcrm:businessContact:remove')")
    @Log(title = "商机和联系人关系表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zxcrmBusinessContactService.deleteZxcrmBusinessContactByIds(ids));
    }
}
